//
//  MyOrderTabBar.m
//  JHStore
//
//  Created by kiefer on 15-3-27.
//  Copyright (c) 2015年 kiefer. All rights reserved.
//
#define RGB(r,g,b) \
[UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:1.f]

#import "MyOrderTabBar.h"
#import "MyOrderTabBarItem.h"


@implementation MyOrderTabBar

- (KZTabBarItem *)createTabBarItem
{
    MyOrderTabBarItem *tabBarItem = [[MyOrderTabBarItem alloc] init];
    tabBarItem.backgroundColor = [UIColor clearColor];
    tabBarItem.font = [UIFont systemFontOfSize:13.0f];
    tabBarItem.titleColor = [UIColor grayColor];
    tabBarItem.titleColorSelected =  [UIColor orangeColor];//color_0xFF3E55;
    
//    UILabel *linLab = [EBUtility labfrome:CGRectMake(0, self.frame.size.height-0.8, SCREEN_WIDTH, 1) andText:@"" andColor:nil andView:tabBarItem];
//    linLab.backgroundColor = RGBA_COLOR(239, 239, 239, 1);
    CALayer *bottomBorder = [CALayer layer];
    float height=tabBarItem.frame.size.height-1.0f;
    float width=tabBarItem.frame.size.width;
    bottomBorder.frame = CGRectMake(0.0f, height, width, 1.0f);
    bottomBorder.backgroundColor = [UIColor redColor].CGColor;
    [tabBarItem.layer addSublayer:bottomBorder];
    
    return tabBarItem;
}

- (void)drawRect:(CGRect)rect
{
    CGFloat width = rect.size.width;
    CGFloat height = rect.size.height;
    CGFloat itemW = width/[self numberOfItems];
    CGFloat itemH = 16;
    
    CGFloat borderWidth = 0.5f;
    UIColor *borderColor = [UIColor grayColor];
    
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetAllowsAntialiasing(ctx, YES);
    CGContextSetStrokeColorWithColor(ctx, borderColor.CGColor);
    CGContextSetLineCap(ctx, kCGLineCapRound);
    CGContextSetLineWidth(ctx, borderWidth);
    
    CGContextBeginPath(ctx);
    
    if ([self numberOfItems] > 0) {
        for (int i = 1; i < [self numberOfItems]; i++) {
            CGContextMoveToPoint(ctx, itemW * i, height/2 - itemH/2);
            CGContextAddLineToPoint(ctx, itemW * i, height/2 + itemH/2);
        }
    }
    
    CGContextClosePath(ctx);
    CGContextDrawPath(ctx, kCGPathStroke);
}

@end
